define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'jdy/devicealarmset/index',
                    add_url: 'jdy/devicealarmset/add',
                    edit_url: 'jdy/devicealarmset/edit',
                    del_url: 'jdy/devicealarmset/del',
                    multi_url: 'jdy/devicealarmset/multi',
                    table: 'jdy_devicealarmset',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                search:false,//不顯示搜索框
                searchFormVisible: true,
                columns: [
                    [
                        //{checkbox: true},
                        {field: 'id', title: __('Id'), operate:false},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate},
                        //{field: 'device_id', title: __('Device_id')},
                        //{field: 'device1_id', title: __('Device1_id')},
                        //{field: 'device2_id', title: __('Device2_id')},
                        {field: 'device.name', title: __('Device.name'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符'},
                        {field: 'device.selfname', title: __('Device.selfname'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符'},
                        //{field: 'warning_type', title: __('Warning_type'), searchList: {"即時告警":__('即時告警'),"延時告警":__('延時告警')}, formatter: Table.api.formatter.normal},
                        //{field: 'warning_status', title: __('Warning_status'), searchList: {"在線":__('在線'),"離線":__('離線')}, formatter: Table.api.formatter.status},
                        //{field: 'delay_time', title: __('Delay_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        //{field: 'replay_time', title: __('Replay_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        //{field: 'warning_switch', title: __('Warning_switch'), searchList: {"開啟":__('開啟'),"關閉":__('關閉')}, formatter: Table.api.formatter.toggle},
                        //{field: 'warning1_status', title: __('Warning1_status'), searchList: {"在線":__('在線'),"離線":__('離線')}, formatter: Table.api.formatter.status},
                        //{field: 'warning_way', title: __('Warning_way'), searchList: {"一般設置":__('一般設置'),"進階設置":__('進階設置')}, formatter: Table.api.formatter.normal},
                        //{field: 'd0_t1', title: __('D0_t1')},
                        //{field: 'd0_t2', title: __('D0_t2')},
                        //{field: 'd0_t3', title: __('D0_t3')},
                        //{field: 'd0_standard_switch', title: __('D0_standard_switch'), searchList: {"開啟":__('開啟'),"關閉":__('關閉')}, formatter: Table.api.formatter.toggle},
                        //{field: 'd0_standard', title: __('D0_standard')},
                        //{field: 'd0_top', title: __('D0_top')},
                        //{field: 'd0_online', title: __('D0_online')},
                        //{field: 'd0_offline', title: __('D0_offline')},
                        //{field: 'd1_t1', title: __('D1_t1')},
                        //{field: 'd1_t2', title: __('D1_t2')},
                        //{field: 'd1_t3', title: __('D1_t3')},
                        //{field: 'd1_standard_switch', title: __('D1_standard_switch'), searchList: {"開啟":__('開啟'),"關閉":__('關閉')}, formatter: Table.api.formatter.toggle},
                        //{field: 'd1_standard', title: __('D1_standard')},
                        //{field: 'd1_top', title: __('D1_top')},
                        //{field: 'd1_online', title: __('D1_online')},
                        //{field: 'd1_offline', title: __('D1_offline')},
                        //{field: 'd2_t1', title: __('D2_t1')},
                        //{field: 'd2_t2', title: __('D2_t2')},
                        //{field: 'd2_t3', title: __('D2_t3')},
                        //{field: 'd2_standard_switch', title: __('D2_standard_switch'), searchList: {"開啟":__('開啟'),"關閉":__('關閉')}, formatter: Table.api.formatter.toggle},
                        //{field: 'd2_standard', title: __('D2_standard')},
                        //{field: 'd2_top', title: __('D2_top')},
                        //{field: 'd2_online', title: __('D2_online')},
                        //{field: 'd2_offline', title: __('D2_offline')},
                        //{field: 'd3_t1', title: __('D3_t1')},
                        //{field: 'd3_t2', title: __('D3_t2')},
                        //{field: 'd3_t3', title: __('D3_t3')},
                        //{field: 'd3_standard_switch', title: __('D3_standard_switch'), searchList: {"開啟":__('開啟'),"關閉":__('關閉')}, formatter: Table.api.formatter.toggle},
                        //{field: 'd3_standard', title: __('D3_standard')},
                        //{field: 'd3_top', title: __('D3_top')},
                        //{field: 'd3_online', title: __('D3_online')},
                        //{field: 'd3_offline', title: __('D3_offline')},
                        //{field: 'd4_t1', title: __('D4_t1')},
                        //{field: 'd4_t2', title: __('D4_t2')},
                        //{field: 'd4_t3', title: __('D4_t3')},
                        //{field: 'd4_standard_switch', title: __('D4_standard_switch'), searchList: {"開啟":__('開啟'),"關閉":__('關閉')}, formatter: Table.api.formatter.toggle},
                        //{field: 'd4_standard', title: __('D4_standard')},
                        //{field: 'd4_top', title: __('D4_top')},
                        //{field: 'd4_online', title: __('D4_online')},
                        //{field: 'd4_offline', title: __('D4_offline')},
                        //{field: 'd5_t1', title: __('D5_t1')},
                        //{field: 'd5_t2', title: __('D5_t2')},
                        //{field: 'd5_t3', title: __('D5_t3')},
                        //{field: 'd5_standard_switch', title: __('D5_standard_switch'), searchList: {"開啟":__('開啟'),"關閉":__('關閉')}, formatter: Table.api.formatter.toggle},
                        //{field: 'd5_standard', title: __('D5_standard')},
                        //{field: 'd5_top', title: __('D5_top')},
                        //{field: 'd5_online', title: __('D5_online')},
                        //{field: 'd5_offline', title: __('D5_offline')},
                        //{field: 'd6_t1', title: __('D6_t1')},
                        //{field: 'd6_t2', title: __('D6_t2')},
                        //{field: 'd6_t3', title: __('D6_t3')},
                        //{field: 'd6_standard_switch', title: __('D6_standard_switch'), searchList: {"開啟":__('開啟'),"關閉":__('關閉')}, formatter: Table.api.formatter.toggle},
                        //{field: 'd6_standard', title: __('D6_standard')},
                        //{field: 'd6_top', title: __('D6_top')},
                        //{field: 'd6_online', title: __('D6_online')},
                        {field: 'luruman', title: __('Luruman')},
                        //{field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        //{field: 'device.id', title: __('Device.id')},
                        //{field: 'device.room_id', title: __('Device.room_id')},
                        //{field: 'device.smallcategory_id', title: __('Device.smallcategory_id')},
                        //{field: 'device.deviceid', title: __('Device.deviceid')},
                        //{field: 'device.category', title: __('Device.category')},
                        //{field: 'device.type', title: __('Device.type')},
                        //{field: 'device.pid', title: __('Device.pid')},
                        //{field: 'device.name', title: __('Device.name')},
                        //{field: 'device.selfname', title: __('Device.selfname')},
                        //{field: 'device.place', title: __('Device.place')},
                        //{field: 'device.version', title: __('Device.version')},
                        //{field: 'device.online', title: __('Device.online')},
                        //{field: 'device.iconVer', title: __('Device.iconver')},
                        //{field: 'device.iconUrl', title: __('Device.iconurl'), formatter: Table.api.formatter.url},
                        //{field: 'device.center', title: __('Device.center')},
                        //{field: 'device.deviceIp', title: __('Device.deviceip')},
                        //{field: 'device.routeMacString', title: __('Device.routemacstring')},
                        //{field: 'device.subType', title: __('Device.subtype')},
                        //{field: 'device.state', title: __('Device.state')},
                        //{field: 'device.updatenum', title: __('Device.updatenum')},
                        //{field: 'device.online_starttime', title: __('Device.online_starttime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        //{field: 'device.create_time', title: __('Device.create_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        //{field: 'device.update_time', title: __('Device.update_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        //{field: 'device.xianshi1', title: __('Device.xianshi1')},
                        //{field: 'device.xzq1', title: __('Device.xzq1')},
                        //{field: 'device.xianshi2', title: __('Device.xianshi2')},
                        //{field: 'device.xzq2', title: __('Device.xzq2')},
                        //{field: 'device.xianshi3', title: __('Device.xianshi3')},
                        //{field: 'device.xzq3', title: __('Device.xzq3')},
                        //{field: 'device.xianshi4', title: __('Device.xianshi4')},
                        //{field: 'device.xzq4', title: __('Device.xzq4')},
                        //{field: 'device.xianshi5', title: __('Device.xianshi5')},
                        //{field: 'device.xzq5', title: __('Device.xzq5')},
                        //{field: 'device.anchangids', title: __('Device.anchangids')},

                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});